package com.zzq.tools;

import com.zzq.tools.comperator.CompareTool;
import com.zzq.tools.comperator.CompareToolAllDb;
import com.zzq.tools.datasource.CompareDataSource;
import com.zzq.tools.datasource.MySqlCompareDataSource;
import com.zzq.tools.result.CompareResult;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class Main {
    public static void main(String[] args) {

        List<CompareDataSource> compareDataSources = new ArrayList<>();
        MySqlCompareDataSource mySqlCompareDataSource1 = new MySqlCompareDataSource
                .MySqlCompareDataSourceBuilder()
                .url("jdbc:mysql://localhost:3306/big_battle")
                .user("root")
                .password("0816")
                .build();
        MySqlCompareDataSource mySqlCompareDataSource2 = new MySqlCompareDataSource
                .MySqlCompareDataSourceBuilder()
                .url("jdbc:mysql://localhost:3306/great_training_compare")
                .user("root")
                .password("0816")
                .build();

        try {
            Connection connection = mySqlCompareDataSource1.getDataSource().getConnection();
            PreparedStatement preparedStatement = connection.prepareStatement("select * from state");
            ResultSet resultSet = preparedStatement.executeQuery();
           while (resultSet.next()) {
               System.out.println(resultSet.getString("id"));
               System.out.println(resultSet.getString("split_state"));
               System.out.println(resultSet.getString("finish_state"));
               System.out.println(resultSet.getString("success"));
               System.out.println(resultSet.getString("failure"));
           }
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }


        CompareTool compareTool = new CompareToolAllDb();

        CompareResult compareResult = compareTool.compareDB(compareDataSources);
//        TxtReporter.report(compareResult);
    }
}